{extend name="common:base" /}
{block name="css_file"}
{/* 页面引入的css文件 */ }
{/block}
{block name="style"}
{/* 页面内嵌CSS */ }
{/block}
{block name="content"}
<div class="row">
    <a class="btn btn-info" href="{:url('index',['act'=>'add'])}" value="">新增</a>
</div>
<div class="space-4"></div>
<div class="row">
<form id="form" method="post" action="{:url('index',['act'=>'del'])}">
    <table class="table table-striped table-bordered table-hover">
    <thead>
        <tr>
            <th class="center"><input class="check-all" type="checkbox" value=""></th>
            <th>用户名</th>
            <th>用户组</th>
            <th class="center">状态</th>
            <th class="center hidden-sm hidden-xs">性别</th>
            <th class="center hidden-sm hidden-xs">生日</th>
            <th class="center hidden-sm hidden-xs">电话</th>
            <th class="center hidden-sm hidden-xs">Q&nbsp;Q</th>
            <th class="center hidden-sm hidden-xs">邮箱</th>
            <th class="center">操作</th>
        </tr>
    </thead>
    <tbody>
    {volist name="list" id="val"}
        <tr>
            <td class="center"><input class="uids" type="checkbox" name="uids[]" value="{$val.uid}"></td>
            <td>{$val.username}</td>
            <td>{$val.title}</td>
            <td class="center">{eq name="val.status" value="1"}启用{else /}<span class="red">禁用</span>{/eq}</td>
            <td class="center hidden-sm hidden-xs">{$val.sex|sex}</td>
            <td class="center hidden-sm hidden-xs">{$val.birthday|date='Y-m-d'}</td>
            <td class="center hidden-sm hidden-xs">{$val.tel}</td>
            <td class="center hidden-sm hidden-xs">{$val.qq}</td>
            <td class="center hidden-sm hidden-xs">{$val.email}</td>
            <td class="center"><a href="{:url('index',['act'=>'edit','uid'=>$val.uid])}"><i class="ace-icon fa fa-edit"></i>编辑</a></td>
        </tr>
    {/volist}
    </tbody>
</table>
</form>
</div>
<div class="row">
    <input id="submit" class="btn btn-info" type="button" value="删除">
</div>
<div class="row">
{$list->render()|raw}
</div>
</div>
{/block}
{block name="js_file"}
<script src="__STATIC__/admin/js/bootbox.js"></script>
{/block}
{block name="javascript"}
<script type="text/javascript">
$(function(){
    $(".check-all").click(function(){
        $(".uids").prop("checked", this.checked);
    });
    $(".uids").click(function(){
        var option = $(".uids");
        option.each(function(i){
            if(!this.checked){
                $(".check-all").prop("checked", false);
                return false;
            }else{
                $(".check-all").prop("checked", true);
            }
        });
    });
    $("#submit").click(function(){
        bootbox.confirm({
            title: "警告",
            message: "确定要删除所选用户？请确保至少保留一位超级管理员用户。",
            callback:function(result){
                if(result){
                    $("#form").submit();
                }
            },
            buttons: {
                "cancel" : {"label" : "取消"},
                "confirm" : {
                        "label" : "确定",
                        "className" : "btn-danger"
                    }
            }
        });
    });
})
</script>
{/block}
